package com.example.sxt_practise.java并发编程;

/**
 * @author gaofeng
 * date 2022年01月03日 10:42
 */
public class TestRunnable {
    public static void main(String[] args) {
        /**
         * 使用Runnable配合Thread
         * 将任务和线程分开
         * java中组合 优于 继承
         */
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                // 要执行的任务
                System.out.println(10 + 5);
            }
        } ;

        // lambda精简带代码
        // @FunctionalInterface注解的都能用lambda精简
        Runnable task = () -> System.out.println(10 + 5);
        Thread thread1 = new Thread(runnable);

        thread1.start();
    }
}
